package com.dxf.redis.pubsub;

import redis.clients.jedis.Jedis;

import java.util.concurrent.locks.ReentrantLock;

public class CustomPublishJedis {

    private final ReentrantLock lock =  new ReentrantLock();

    private String channel;

    private Jedis jedis;


    public CustomPublishJedis(String channel, Jedis jedis) {
        this.channel = channel;
        this.jedis = jedis;
    }

    public void publish(String mess){
        lock.lock();
        jedis.publish(channel,mess);
        lock.unlock();

    }
}
